package com.design.classroommanagement.util;

import java.sql.PreparedStatement;

public class UserRegister extends DBUtils {
    PreparedStatement prepare;
    //添加用户的方法
    public boolean insert(String table,String id,String password) throws Exception{

        try {
            conn = DBUtils.getConnect();
            if(table=="teacher"){
                String sql = "insert into teacher(name,Password)VALUES(?,?)";
                prepare=conn.prepareStatement(sql);
            }else if(table=="admin"){
                String sql = "insert into admin(Ano,Password)VALUES(?,?)";
                prepare=conn.prepareStatement(sql);
            }else if(table=="student"){
                String sql = "insert into student(Sno,Password)VALUES(?,?)";
                prepare=conn.prepareStatement(sql);
            }


            prepare.setString(1,id);
            prepare.setString(2,password);
            prepare.execute();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
        return true;
    }
}
